<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="https://www.thymeleaf.org"
      xmlns:sec="https://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head>
    <title>Spring Security Example </title>
</head>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
    function changeCode() {
        const src = "/getVerifyCode?" + new Date().getTime(); //加时间戳，防止浏览器利用缓存
        $('.verifyCode').attr("src", src);
    }
</script>
<body>
<div th:if="${param.error}">
    Invalid username and password.
</div>
<div th:if="${param.logout}">
    You have been logged out.
</div>
<a href="javascript:void(0);" rel="external nofollow" title="点击更换验证码">
    <img th:src="@{getVerifyCode}" onclick="changeCode()" class="verifyCode"/>
</a>

<form th:action="@{/login}" method="post">
    <div><label> User Name : <input type="text" name="username"/> </label></div>
    <div><label> Password: <input type="password" name="password"/> </label></div>
    <div><label> verifyCode: <input type="text" name="code"/> </label></div>
    <div><input type="submit" value="Sign In"/></div>
</form>
</body>
</html>